<?
include("../header.php");
//ob_start();
//session_start();
?>
<link rel="stylesheet" type="text/css" href="../style/style.css" />
<?
include("config.php");
include("function.php");
// get kategori form
$show			= $HTTP_POST_VARS['cat'];
// get data form employee
$nik			= $HTTP_POST_VARS['nik'];
$code_area		= $HTTP_POST_VARS['code_area'];
$nama			= $HTTP_POST_VARS['nama'];
$tempat_lahir	= $HTTP_POST_VARS['tempat_lahir'];
$tgl_lahir		= $HTTP_POST_VARS['tgl_lahir'];
$status			= $HTTP_POST_VARS['status'];
$gender			= $HTTP_POST_VARS['gender'];
$agama			= $HTTP_POST_VARS['agama'];
$alamat			= $HTTP_POST_VARS['alamat'];
$kelurahan		= $HTTP_POST_VARS['kelurahan'];
$kecamatan		= $HTTP_POST_VARS['kecamatan'];
$kota			= $HTTP_POST_VARS['kota'];
$kode_pos		= $HTTP_POST_VARS['kode_pos'];
$propinsi		= $HTTP_POST_VARS['propinsi'];
$negara			= $HTTP_POST_VARS['negara'];
$warga_negara	= $HTTP_POST_VARS['warga_negara'];
$no_ktp			= $HTTP_POST_VARS['no_ktp'];
$telepon		= $HTTP_POST_VARS['telepon'];
$email			= $HTTP_POST_VARS['email'];
$scope			= $HTTP_POST_VARS['scope'];
// get data from pendidikan formal
$no				= $HTTP_POST_VARS['no'];
$nama_kampus	= $HTTP_POST_VARS['nama_kampus'];
$tempat			= $HTTP_POST_VARS['tempat'];
$sampai_kelas	= $HTTP_POST_VARS['sampai_kelas'];
$dari			= $HTTP_POST_VARS['dari'];
$sampai			= $HTTP_POST_VARS['sampai'];
$no_ijazah		= $HTTP_POST_VARS['no_ijazah'];
$tgl_ijazah		= $HTTP_POST_VARS['tgl_ijazah'];
$ipk			= $HTTP_POST_VARS['ipk'];
$jenjang		= $HTTP_POST_VARS['jenjang'];
$fakultas		= $HTTP_POST_VARS['fakultas'];
$jurusan		= $HTTP_POST_VARS['jurusan'];
$tgl_kadaluarsa = $HTTP_POST_VARS['tgl_kadaluarsa'];
// get data from pendidikan non formal/kursus
$program		= $HTTP_POST_VARS['program'];
$penyelenggara	= $HTTP_POST_VARS['penyelenggara'];
$lama			= $HTTP_POST_VARS['lama'];
$jam			= $HTTP_POST_VARS['jam'];
(int) $jenis			= $HTTP_POST_VARS['jenis'];
(int) $no_sertifikat	= $HTTP_POST_VARS['no_sertifikat'];
$tgl_sertifikat	= $HTTP_POST_VARS['tgl_sertifikat'];
$masa_sertifikat= $HTTP_POST_VARS['masa_sertifikat'];
$keterangan		= $HTTP_POST_VARS['keterangan'];
(int) $profesi		= $HTTP_POST_VARS['profesi'];
(int) $sertifikat		= $HTTP_POST_VARS['profesi'];
(int) $brevet 		= $HTTP_POST_VARS['brevet'];
(int) $intern 		= $HTTP_POST_VARS['intern'];
$bea_training 	= $HTTP_POST_VARS['bea_training'];
$bea_transport 	= $HTTP_POST_VARS['bea_transport'];
$bea_lain 		= $HTTP_POST_VARS['bea_lain'];
$bea_akomodasi 	= $HTTP_POST_VARS['bea_akomodasi'];
$ikatan_dinas	= $HTTP_POST_VARS['ikatan_dinas'];
$awal_ikatan	= $HTTP_POST_VARS['awal_ikatan'];
$akhir_ikatan	= $HTTP_POST_VARS['akhir_ikatan'];
$laporan		= $HTTP_POST_VARS['laporan'];
(int) $sertifikat = $HTTP_POST_VARS['sertifikat'];
$nama_sertifikat= $HTTP_POST_VARS['nama_sertifikat'];
// get data from from keluarga
$nama_keluarga	= $HTTP_POST_VARS['nama_keluarga'];
$hubungan 		= $HTTP_POST_VARS['hubungan'];
$pendidikan 	= $HTTP_POST_VARS['pendidikan'];
$pekerjaan 		= $HTTP_POST_VARS['pekerjaan'];
$alamat			= $HTTP_POST_VARS['alamat'];
$tertanggung	= $HTTP_POST_VARS['tertanggung'];
// get data from form karir
$instansi		= $HTTP_POST_VARS['instansi'];
$jabatan		= $HTTP_POST_VARS['jabatan'];
$gaji			= $HTTP_POST_VARS['gaji'];
$tunjangan		= $HTTP_POST_VARS['tunjangan'];
$alasan			= $HTTP_POST_VARS['alasan'];
// get data from form organisasi
$nama_organisasi= $HTTP_POST_VARS['nama_organisasi'];
if(trim($HTTP_POST_VARS['jabatan2']) == ""){
	$jabatan2		= 0;
}
else{
	$jabatan2		= $HTTP_POST_VARS['jabatan2'];
}
//$fungsi2		= $HTTP_POST_VARS['fungsi2'];

if(trim($HTTP_POST_VARS['fungsi2']) == ""){
	$fungsi2		= 0;
}
else{
	$fungsi2		= $HTTP_POST_VARS['fungsi2'];
}
// get data from form data pribadi
$fakultas		= $HTTP_POST_VARS['fakultas'];
$spesialisasi	= $HTTP_POST_VARS['spesialisasi'];
$keahlian		= $HTTP_POST_VARS['keahlian'];
$studi			= $HTTP_POST_VARS['studi'];
$tugas_akhir	= $HTTP_POST_VARS['tugas_akhir'];
$tinggi			= $HTTP_POST_VARS['tinggi'];
$berat			= $HTTP_POST_VARS['berat'];
$hobby			= $HTTP_POST_VARS['hobby'];
$olahraga		= $HTTP_POST_VARS['olahraga'];
$sakit_keras	= $HTTP_POST_VARS['sakit_keras'];
$waktu_sakit	= $HTTP_POST_VARS['waktu_sakit'];
$nama_penyakit	= $HTTP_POST_VARS['nama_penyakit'];
$kecelakaan		= $HTTP_POST_VARS['kecelakaan'];
$jenis_celaka	= $HTTP_POST_VARS['jenis_celaka'];
$akibat_celaka	= $HTTP_POST_VARS['akibat_celaka'];
$terlarang		= $HTTP_POST_VARS['terlarang'];
$urusan_polisi	= $HTTP_POST_VARS['urusanpolisi'];
$astek			= $HTTP_POST_VARS['astek'];
$no_astek		= $HTTP_POST_VARS['no_astek'];
$penataranp4	= $HTTP_POST_VARS['penataranp4'];
$waktup4		= $HTTP_POST_VARS['waktu_penataran'];
$typep4			= $HTTP_POST_VARS['type_penataran'];
$penyelenggarap4= $HTTP_POST_VARS['penyelenggara'];
$sim			= $HTTP_POST_VARS['sim'];
$semua_wilayah	= $HTTP_POST_VARS['semua_wilayah'];
$semua_peraturan= $HTTP_POST_VARS['semua_peraturan'];
$jenis_urusan	= $HTTP_POST_VARS['jenis_urusan'];
$waktu_celaka	= $HTTP_POST_VARS['waktu_celaka'];
// form bahasa
$bahasa			= $HTTP_POST_VARS['bahasa'];
$aktif			= $HTTP_POST_VARS['aktif'];
// form status karyawan
$status_kerja	= $HTTP_POST_VARS['status_kerja'];
(int) $status_karyawan = $HTTP_POST_VARS['status_karyawan'];
$golongan		= $HTTP_POST_VARS['golongan'];
$cara_kerja		= $HTTP_POST_VARS['cara_kerja'];
$tamat_jabatan	= $HTTP_POST_VARS['tamat_jabatan'];
$tamat_golongan	= $HTTP_POST_VARS['tamat_golongan'];
$tgl_masuk		= $HTTP_POST_VARS['tgl_masuk'];
$tgl_keluar		= $HTTP_POST_VARS['tgl_keluar'];
$tgl_nikah		= $HTTP_POST_VARS['tgl_nikah'];
$fungsi			= $HTTP_POST_VARS['fungsi'];
$kode_so		= $HTTP_POST_VARS['kode_so'];
//form karir di ptsi
$no_surat		= $HTTP_POST_VARS['no_surat'];
$jenis_surat	= $HTTP_POST_VARS['jenis_surat'];
$tgl_efektif	= $HTTP_POST_VARS['tgl_efektif'];
$tgl_skd		= $HTTP_POST_VARS['tgl_skd'];
$tgl_selesai	= $HTTP_POST_VARS['tgl_selesai'];
$tgl_hangus		= $HTTP_POST_VARS['tgl_hangus'];
$seksi1			= $HTTP_POST_VARS['seksi1'];
$seksi2			= $HTTP_POST_VARS['seksi2'];
$lokasi1		= $HTTP_POST_VARS['lokasi1'];
$lokasi2		= $HTTP_POST_VARS['lokasi2'];
$jabatan1		= $HTTP_POST_VARS['jabatan1'];
//$jabatan2		= $HTTP_POST_VARS['jabatan2'];
$fungsi1		= $HTTP_POST_VARS['fungsi1'];
//$fungsi2		= $HTTP_POST_VARS['fungsi2'];
$gol1			= $HTTP_POST_VARS['gol1'];
$gol2			= $HTTP_POST_VARS['gol2'];
$status_karyawan1 = $HTTP_POST_VARS['status_karyawan1'];
$status_karyawan2 = $HTTP_POST_VARS['status_karyawan2'];
$kelompok		= $HTTP_POST_VARS['kelompok'];
// form track record
$track_start	= $HTTP_POST_VARS['track_start'];
$track_end		= $HTTP_POST_VARS['track_end'];
$client			= $HTTP_POST_VARS['client'];
$product		= $HTTP_POST_VARS['product'];
$project		= $HTTP_POST_VARS['project'];
$job_desc		= $HTTP_POST_VARS['job_desc'];
// form sanksi
$tgl_berlaku	= $HTTP_POST_VARS['tgl_berlaku'];
$sanksi			= $HTTP_POST_VARS['sanksi'];
$info_detail	= $HTTP_POST_VARS['info_detail'];
$seksi			= $HTTP_POST_VARS['seksi'];
$nama_jabatan	= $HTTP_POST_VARS['nama_jabatan'];
$lokasi			= $HTTP_POST_VARS['lokasi'];
// form penugasan
$tgl_surat		= $HTTP_POST_VARS['tgl_surat'];
$tgl_dari		= $HTTP_POST_VARS['tgl_dari'];
$tgl_sampai		= $HTTP_POST_VARS['tgl_sampai'];
$tujuan			= $HTTP_POST_VARS['tujuan'];
$keperluan		= $HTTP_POST_VARS['keperluan'];
$bagian			= $HTTP_POST_VARS['bagian'];
$detail_posisi	= $HTTP_POST_VARS['detail_posisi'];
// form penilaian
$unsur			= $HTTP_POST_VARS['unsur'];
$tahun			= $HTTP_POST_VARS['tahun'];
$nilai1			= $HTTP_POST_VARS['nilai1'];
$nilai2			= $HTTP_POST_VARS['nilai2'];
$nilai3			= $HTTP_POST_VARS['nilai3'];
$catatan		= $HTTP_POST_VARS['catatan'];
// form LP2
$nik2			= $HTTP_POST_VARS['nik2'];
$nik3			= $HTTP_POST_VARS['nik3'];
$nik4			= $HTTP_POST_VARS['nik4'];
$nama2			= $HTTP_POST_VARS['nama2'];
$nama3			= $HTTP_POST_VARS['nama3'];
$nama4			= $HTTP_POST_VARS['nama4'];
// form CUTI
$tgl_mulai			= $HTTP_POST_VARS['tgl_mulai'];
(int) $jenis_cuti	= $HTTP_POST_VARS['jenis_cuti'];
(int) $jumlah_cuti	= $HTTP_POST_VARS['jumlah_cuti'];
// form plafon awal
$periode			= $HTTP_POST_VARS['periode'];
$date_setup			= $HTTP_POST_VARS['date_setup'];
$plafon_rawat_jalan	= $HTTP_POST_VARS['plafon_rawat_jalan'];
$plafon_rawat_inap	= $HTTP_POST_VARS['plafon_rawat_inap'];
$plafon_kaca_mata	= $HTTP_POST_VARS['plafon_kaca_mata'];
// form rekening
$no_rek			= $HTTP_POST_VARS['no_rek'];
$nama_rek		= $HTTP_POST_VARS['nama_rek'];
$nama_bank		= $HTTP_POST_VARS['nama_bank'];
// form medical karyawan
$no_restitusi	= $HTTP_POST_VARS['no_restitusi'];
$tgl_restitusi	= $HTTP_POST_VARS['tgl_restitusi'];
$tgl_bayar		= $HTTP_POST_VARS['tgl_bayar'];
$diperiksa_oleh	= $HTTP_POST_VARS['diperiksa_oleh'];
$diajukan_oleh	= $HTTP_POST_VARS['diajukan_oleh'];
$tgl_kwitansi		= $HTTP_POST_VARS['tgl_kwitansi'];
$nama_tertanggung 	= $HTTP_POST_VARS['nama_tertanggung'];
$nama_dokter		= $HTTP_POST_VARS['nama_dokter'];
// form parameter lokasi
$kode_lokasi	= $HTTP_POST_VARS['kode_lokasi'];
$distrik		= $HTTP_POST_VARS['distrik'];
// form parameter lp2
$kode_nilai		= $HTTP_POST_VARS['kode_penilaian'];
$unsur_nilai	= $HTTP_POST_VARS['unsur_penilaian'];
//---------
// form parameter fungsional
$kode_fungsi	= $HTTP_POST_VARS['kode_fungsi'];
$nama_fungsi	= $HTTP_POST_VARS['nama_fungsi'];
// form parameter jenis cuti
$nama_cuti		= $HTTP_POST_VARS['nama_cuti'];
(int) $jatah_cuti		= $HTTP_POST_VARS['jatah_cuti'];
(int) $syarat_waktu		= $HTTP_POST_VARS['syarat_waktu'];
(int) $akumulasi		= $HTTP_POST_VARS['akumulasi'];
(int) $otorisasi		= $HTTP_POST_VARS['otorisasi'];
(int) $istimewa			= $HTTP_POST_VARS['istimewa'];
(int) $syarat_sex		= $HTTP_POST_VARS['syarat_sex'];
//-------------------------------------------------------//
// form parameter pendidikna
$jurusan		= $HTTP_POST_VARS['jurusan'];
$teknik			= $HTTP_POST_VARS['teknik'];
// form parameter bank
$cabang		= $HTTP_POST_VARS['cabang'];
// form parameter jabatan
$level_jabatan	= $HTTP_POST_VARS['level_jabatan'];
$fungsional		= $HTTP_POST_VARS['fungsional'];
// form parameter setup
$code			= $HTTP_POST_VARS['code'];
$groupcode		= $HTTP_POST_VARS['groupcode'];
$remarks		= $HTTP_POST_VARS['remarks'];
$idcode			= $HTTP_POST_VARS['id_code'];
// form user
$group_code		= $HTTP_POST_VARS['group_code'];
$username		= $HTTP_POST_VARS['username'];
$password		= $HTTP_POST_VARS['password'];
// form group user
// form add group user
$menuname	= $HTTP_POST_VARS['menuname'];
$priv		= $HTTP_POST_VARS['priv'];
$group_name	= $HTTP_POST_VARS['group_name'];
// form change password
$pass_lama		= $HTTP_POST_VARS['pass_lama'];
$pass_baru		= $HTTP_POST_VARS['pass_baru'];
$conf_pass_baru	= $HTTP_POST_VARS['conf_pass_baru'];
// form table unit kerja
$uraian		= $HTTP_POST_VARS['uraian'];
$areacode	= $HTTP_POST_VARS['area_code'];
$levelso	= $HTTP_POST_VARS['levelso'];

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
if(trim($HTTP_POST_VARS['beban_RI_prsh']) == ""){
	$beban_RI_prsh = 0;
}
else{
	$beban_RI_prsh = $HTTP_POST_VARS['beban_RI_prsh'];
}
//---------
if(trim($HTTP_POST_VARS['beban_RI_kar']) == ""){
	$beban_RI_kar = 0; 
}
else{
	$beban_RI_kar = $HTTP_POST_VARS['beban_RI_kar'];
}
//----------
if(trim($HTTP_POST_VARS['beban_PR_prsh']) == ""){
	$beban_PR_prsh = 0;
}
else{
	$beban_PR_prsh	= $HTTP_POST_VARS['beban_PR_prsh'];
}
//----------
if(trim($HTTP_POST_VARS['beban_PR_kar']) == ""){
	$beban_PR_kar = 0;
}
else{
	$beban_PR_kar = $HTTP_POST_VARS['beban_PR_kar'];
}
//----------
if(trim($HTTP_POST_VARS['status_kel_restitusi']) == ""){
	$status_kel_restitusi = 0;
}
else{
	$status_kel_restitusi = $HTTP_POST_VARS['status_kel_restitusi'];
}
//----------
if(trim($HTTP_POST_VARS['mata_anggaran']) == ""){
	$mata_anggaran = 0;
}
else{
	$mata_anggaran	= $HTTP_POST_VARS['mata_anggaran'];
}
//----------
if(trim($HTTP_POST_VARS['cara_bayar']) == ""){
	$cara_bayar = 0;
}
else{
	$cara_bayar	= $HTTP_POST_VARS['cara_bayar'];
}
//----------
if(trim($HTTP_POST_VARS['klaim_RJ']) == ""){
	$klaim_RJ = 0;
}
else{
	$klaim_RJ = $HTTP_POST_VARS['klaim_RJ'];
}
//----------
if(trim($HTTP_POST_VARS['klaim_KM']) == ""){
	$klaim_KM = 0;
}
else{
	$klaim_KM = $HTTP_POST_VARS['klaim_KM'];
}
//----------
if(trim($HTTP_POST_VARS['klaim_RI']) == "" ){
	$klaim_RI = 0;
}
else{
	$klaim_RI = $HTTP_POST_VARS['klaim_RI'];
}
//----------
if(trim($HTTP_POST_VARS['setuju_RJ']) == ""){
	$setuju_RJ = 0;
}
else{
	$setuju_RJ = $HTTP_POST_VARS['setuju_RJ'];
	//echo $HTTP_POST_VARS['setuju_RJ'];
	//exit;
}
//----------
if(trim($HTTP_POST_VARS['setuju_KM']) == ""){
	$setuju_KM = 0;
}
else{
	$setuju_KM = $HTTP_POST_VARS['setuju_KM'];
	//echo $HTTP_POST_VARS['setuju_KM'];
	//exit;
}
//----------
if(trim($HTTP_POST_VARS['setuju_RI']) == ""){
	$setuju_RI = 0;
}
else{
	$setuju_RI = $HTTP_POST_VARS['setuju_RI'];
}

// untuk list penilaian karyawan
$penilai_atasan1	= $HTTP_POST_VARS['nik_atasan1'];
$penilai_atasan2	= $HTTP_POST_VARS['nik_atasan2'];
$penilai_peers1		= $HTTP_POST_VARS['nik_peers1'];
$penilai_peers2		= $HTTP_POST_VARS['nik_peers2'];
$penilai_peers3		= $HTTP_POST_VARS['nik_peers3'];
$penilai_adum		= $HTTP_POST_VARS['nik_adum'];
$id		= $HTTP_POST_VARS['id'];
////////////
if($show == "employee"){
	$d			= substr($tgl_lahir,0,2); // day
	$m			= substr($tgl_lahir,3,2); // month
	$y			= substr($tgl_lahir,6,4); // year
	$tanggal 	= $y."-".$m."-".$d; // date yyyy-mm-dd
	
	$file 			= $_FILES['file']['name'];
	// upload images 
	$uploaddir 		= getcwd(); // get path 
	// gbr proposal
	$uploadfile 	= "$uploaddir/../file_photo/$file"; //place upload file
	$dirimage		= "$uploaddir/../file_photo";
	$ext			= substr($file,-3); // get extension
	
	// UPLOAD IMAGE
	if ($_FILES['file']['tmp_name'] != "" )
	{
		if($ext == "GIF" || $ext == "gif" || $ext == "JPG" || $ext == "jpg")
		{
			list($width, $height, $type, $attr) = getimagesize($_FILES['file']['tmp_name']);
			if($width <= 102 && $height <= 120)
			{
				if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) 
				{
					if(!empty($HTTP_POST_VARS['foto']))
					{
						if(file_exists("$dirimage/".$HTTP_POST_VARS['foto']."")){
							// delete foto lama
							if(unlink("$dirimage/".$HTTP_POST_VARS['foto']."")){
								// rename photo
								$new_file = $nik.".".$ext;
								if(rename("$uploadfile","$dirimage/$new_file")){
									// update data ///////////////////////////////////////////////		
									$sql = "UPDATE Karyawan SET AreaCode='$code_area', Nama='$nama',TempatLahir='$tempat_lahir',Tgl_Lahir='$tanggal',Status='$status',JKel='$gender',Agama='$agama',Alamat='$alamat',Kelurahan='$kelurahan',Kecamatan='$kecamatan',Kota='$kota',KodePos='$kode_pos',Propinsi='$propinsi',Negara='$negara',WargaNegara='$warga_negara',NomorKTP='$no_ktp',NoTelepon='$telepon',Email='$email',Foto='$new_file' WHERE NIK='$nik'";
											
									$cat = "update"; // category query
									InsertDataEmp($conn,$sql,$cat,$nik);
									// end of update data ///////////////////////////////////////////
								}						
							}
							else{
								exit;
							}
						}
						else{
							// rename photo
							$new_file = $nik.".".$ext;
							if(rename("$uploadfile","$dirimage/$new_file")){
								// update data ///////////////////////////////////////////////		
								$sql = "UPDATE Karyawan SET AreaCode='$code_area', Nama='$nama',TempatLahir='$tempat_lahir',Tgl_Lahir='$tanggal',Status='$status',JKel='$gender',Agama='$agama',Alamat='$alamat',Kelurahan='$kelurahan',Kecamatan='$kecamatan',Kota='$kota',KodePos='$kode_pos',Propinsi='$propinsi',Negara='$negara',WargaNegara='$warga_negara',NomorKTP='$no_ktp',NoTelepon='$telepon',Email='$email',Foto='$new_file' WHERE NIK='$nik'";
										
								$cat = "update"; // category query
								InsertDataEmp($conn,$sql,$cat,$nik);
								// end of update data ///////////////////////////////////////////
							}						
						}
					}
					else{
								// rename photo
								$new_file = $nik.".".$ext;
								if(rename("$uploadfile","$dirimage/$new_file")){
									// update data ///////////////////////////////////////////////		
									$sql = "UPDATE Karyawan SET AreaCode='$code_area', Nama='$nama',TempatLahir='$tempat_lahir',Tgl_Lahir='$tanggal',Status='$status',JKel='$gender',Agama='$agama',Alamat='$alamat',Kelurahan='$kelurahan',Kecamatan='$kecamatan',Kota='$kota',KodePos='$kode_pos',Propinsi='$propinsi',Negara='$negara',WargaNegara='$warga_negara',NomorKTP='$no_ktp',NoTelepon='$telepon',Email='$email',Foto='$new_file' WHERE NIK='$nik'";
											
									$cat = "update"; // category query
									InsertDataEmp($conn,$sql,$cat,$nik);
									// end of update data ///////////////////////////////////////////
					}
				}}
				else{
					echo"<Br><br><font color='red'>Maaf, File yang Anda upload terlalu besar</red><br><br>[ <a href='javascript:history.back()'>kembali</a> ]";
				}
			}
			else{
				echo"<Br><br><font color='red'>Maaf, Maksimal Dimensi gambar 102px X 120px </red> <br><br>[ <a href='javascript:history.back()'>kembali</a> ]";
			}
		}
		else
		{
		echo"<br><br>
			<div >
			<table cellpadding='8' bgcolor='#FCFCFE' style='font-family: verdana; font-size: 11px; color: #000000; border:solid 1px #919B9C;' align='center'>
			<tr>
			<td valign=middle>
			</td>
			<td valign='middle'>
			Maaf, File yang Anda masukkan harus dalam format <b>\" .gif atau .jpg  \"</b>
			</td>
			</tr>
			<tr>
			<td colspan=2 align=center>
			<a href='#' onclick='javascript:history.back(); return false;'>Silahkan Kembali</a>
			</td>
			</div>";
			//exit;
		}
	}
	else{
		// update data ///////////////////////////////////////////////		
		$sql = "UPDATE Karyawan SET AreaCode='$code_area', Nama='$nama',TempatLahir='$tempat_lahir',Tgl_Lahir='$tanggal',Status='$status',JKel='$gender',Agama='$agama',Alamat='$alamat',Kelurahan='$kelurahan',Kecamatan='$kecamatan',Kota='$kota',KodePos='$kode_pos',Propinsi='$propinsi',Negara='$negara',WargaNegara='$warga_negara',NomorKTP='$no_ktp',NoTelepon='$telepon',Email='$email' WHERE NIK='$nik'";
				
		$cat = "update"; // category query
		InsertDataEmp($conn,$sql,$cat,$nik);
		// end of update data ///////////////////////////////////////////
	}			
}
///////////////////////////////////
elseif($show == "cat_lp2"){
	//echo"fdfd";
	// delete data
	$sd = mssql_query("DELETE FROM S_LP_Cat_Nilai WHERE category='".$HTTP_POST_VARS['category']."'",$conn);
	if($sd){
		$idu = $HTTP_POST_VARS['id_unsur'];
		for($j=0;$j<count($idu);$j++){
			mssql_query("INSERT INTO S_LP_Cat_Nilai (category,unsur_penilai) VALUES ('".$HTTP_POST_VARS['category']."','".$idu[$j]."') ");
		}
		echo"
			<div align=center>
				<br><br><br>
				Data sudah diupdate ...<br><br>
				<a href='Javascript:history.go(-2);'>Silahkan Kembali</a>
				
			</div>
		";
	}
	else{
		echo"Bad ...";
	}
	// insert data
}
elseif($show == "pendidikan"){
	// tanggal DARI
	$d			= substr($dari,0,2); // day
	$m			= substr($dari,3,2); // month
	$y			= substr($dari,6,4); // year
	$tgl_dari 	= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tanggal SAMPAI
	$d1			= substr($sampai,0,2); // day
	$m1			= substr($sampai,3,2); // month
	$y1			= substr($sampai,6,4); // year
	$tgl_sampai	= $y1."-".$m1."-".$d1; // date yyyy-mm-dd
	// tanggal IJAZAH
	$d3			= substr($tgl_ijazah,0,2); // day
	$m3			= substr($tgl_ijazah,3,2); // month
	$y3			= substr($tgl_ijazah,6,4); // year
	$tglijazah	= $y3."-".$m3."-".$d3; // date yyyy-mm-dd

	$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY Dari) AS no, * FROM Pendidikan WHERE NIK='$nik' ) UPDATE limit SET Pend_ID='$jenjang',NamaKampus='$nama_kampus',Tempat='$tempat',SampaiKelas='$sampai_kelas',Dari='$tgl_dari',Sampai='$tgl_sampai',No_Ijasah='$no_ijazah',Tgl_Ijasah='$tglijazah',IPK='$ipk',jenjang_id='$jenjang',fakultas_id='$fakultas',jurusan_id='$jurusan' WHERE no='$no'  ";
				
	$cat = "update"; // category query
	InsertDataEmp($conn,$sql,$cat,$nik);
}
/////////////////////////////////////KURSUS/NONFORMAL/////
elseif($show == "kursus"){
	// tanggal DARI
	$d			= substr($dari,0,2); // day
	$m			= substr($dari,3,2); // month
	$y			= substr($dari,6,4); // year
	$tgl_dari 	= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tanggal SAMPAI
	$d1			= substr($sampai,0,2); // day
	$m1			= substr($sampai,3,2); // month
	$y1			= substr($sampai,6,4); // year
	$tgl_sampai	= $y1."-".$m1."-".$d1; // date yyyy-mm-dd
	// tanggal SERTIFIKAT
	$d3			= substr($tgl_sertifikat,0,2); // day
	$m3			= substr($tgl_sertifikat,3,2); // month
	$y3			= substr($tgl_sertifikat,6,4); // year
	$tglsertifikat	= $y3."-".$m3."-".$d3; // date yyyy-mm-dd
	// masa SERTIFIKAT
	$d4			= substr($masa_sertifikat,0,2); // day
	$m4			= substr($masa_sertifikat,3,2); // month
	$y4			= substr($masa_sertifikat,6,4); // year
	$masaSertifikat	= $y4."-".$m4."-".$d4; // date yyyy-mm-dd
	// AWAL IKATAN
	$d5			= substr($awal_ikatan,0,2); // day
	$m5			= substr($awal_ikatan,3,2); // month
	$y5			= substr($awal_ikatan,6,4); // year
	$AwalIkatan	= $y5."-".$m5."-".$d5; // date yyyy-mm-dd
	// AKHIR IKATAN
	$d6			= substr($akhir_ikatan,0,2); // day
	$m6			= substr($akhir_ikatan,3,2); // month
	$y6			= substr($akhir_ikatan,6,4); // year
	$AkhirIkatan	= $y6."-".$m6."-".$d6; // date yyyy-mm-dd

	$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) as No, * FROM Kursus WHERE NIK='$nik') UPDATE limit SET Program='$program', Penyelenggara='$penyelenggara', Tempat='$tempat', Lama='$lama', Jam='$jam', Dari='$tgl_dari', Sampai='$tgl_sampai', Jenis='$jenis', NoSertifikat='$no_sertifikat', TglSertifikat='$tglsertifikat', MasaSertifikat='$masaSertifikat', Keterangan='$keterangan', Profesi='$profesi', Brevet='$brevet', Intern='$intern', Sertifikat='$sertifikat', BiayaTraining='$bea_training', BiayaAkomodasi='$bea_akomodasi', BiayaTransport='$bea_transport', BiayaLain='$bea_lain', IkatanDinas='$ikatan_dinas', AwalIkatan='$AwalIkatan', AkhirIkatan='$AkhirIkatan', Laporan='$laporan' Where No='$no'   ";
				
	$cat = "update"; // category query
	InsertDataEmp($conn,$sql,$cat,$nik);
}
/////////////////////////////////////KELUARGA/FAMILY/////
elseif($show == "keluarga"){
	// tanggal DARI
	$d			= substr($tgl_lahir,0,2); // day
	$m			= substr($tgl_lahir,3,2); // month
	$y			= substr($tgl_lahir,6,4); // year
	$tanggal 	= $y."-".$m."-".$d; // date yyyy-mm-dd

	$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY Nm_Keluarga) as No, * FROM Keluarga WHERE NIK='$nik') UPDATE limit SET  Nm_Keluarga='$nama_keluarga', Hubungan='$hubungan', JKel='$gender', TempatLahir='$tempat_lahir', Tgl_Lahir='$tanggal', TingkatPendidikan='$pendidikan', Pekerjaan='$pekerjaan', Alamat='$alamat', IsTertanggung='$tertanggung' Where No='$no'   ";
				
	$cat = "update"; // category query
	InsertDataEmp($conn,$sql,$cat,$nik);
	//($conn,$sql,$cat,$nik)
}
////////////////////UPLOAD FILE////////////////////
elseif($show == "upload_file"){
	$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) as No, * FROM S_File_Emp WHERE NIK='$nik') UPDATE limit SET nama_file='$nama' Where No='$no'";
				
	$cat = "update"; // category query
	InsertDataEmp($conn,$sql,$cat,$nik);
}
/////////////////////////////////////KARIR////
elseif($show == "karir"){
	// tanggal DARI
	$d			= substr($dari,0,2); // day
	$m			= substr($dari,3,2); // month
	$y			= substr($dari,6,4); // year
	$tgl_dari 	= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tanggal SAMPAI
	$d1			= substr($sampai,0,2); // day
	$m1			= substr($sampai,3,2); // month
	$y1			= substr($sampai,6,4); // year
	$tgl_sampai	= $y1."-".$m1."-".$d1; // date yyyy-mm-dd

	$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) as No, * FROM Karir WHERE NIK='$nik') UPDATE limit SET instansi='$instansi', scope_of_works='$scope', jabatan='$jabatan', dari='$tgl_dari', sampai='$tgl_sampai', gaji='$gaji', tunjangan='$tunjangan', alasan='$alasan' FROM Karir Where No='$no'   ";
				
	$cat = "update"; // category query
	InsertDataEmp($conn,$sql,$cat,$nik);
}
///////////////ORGANISASI//////////
elseif($show == "organisasi"){

	$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) as No, * FROM Organisasi WHERE NIK='$nik') UPDATE limit SET OrgName='$nama_organisasi', OrgPlace='$alamat', OrgTitle='$jabatan2' Where No='$no'   ";
				
	$cat = "update"; // category query
	InsertDataEmp($conn,$sql,$cat,$nik);
}
///////////////PRIBADI//////////
elseif($show == "pribadi"){

	//$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) as No, * FROM Organisasi WHERE NIK='$nik') UPDATE limit SET OrgName='$nama_organisasi', OrgPlace='$alamat', OrgTitle='$jabatan2' Where No='$no'   ";
	$sql = "UPDATE Pribadi SET 
			Nm_Kampus='$nama_kampus', 
			Fakultas='$fakultas', 
			Pend_ID='$jenjang', 
			Spesialisasi='$spesialisasi', 
			Keahlian='$keahlian', 
			Studi='$studi', 
			TugasAkhir='$tugas_akhir', 
			Tinggi='$tinggi', 
			Berat='$berat', 
			Hobby='$hobby', 
			OlahRaga='$olahraga',
			SakitKeras='$sakit_keras', 
			WaktuSakit='$waktu_sakit', 
			NamaPenyakit='$nama_penyakit', 
			Kecelakaan='$kecelakaan', 
			WaktuCelaka='$waktu_celaka', 
			JenisCelaka='$jenis_celaka', 
			AkibatCelaka='$akibat_celaka',
			Terlarang='$terlarang', 
			UrusanKepolisian='$urusan_polisi', 
			JenisUrusan='$jenis_urusan', 
			Astek='$astek', 
			NoAstek='$no_astek', 
			P4='$penataranp4', 
			WaktuP4='$waktup4', 
			TypeP4='$typep4', 
			PenyelenggaraP4='$penyelenggarap4', 
			SIM='$sim', 
			TunjanganSebelumnya='$tunjangan', 
			Gaji='$gaji', 
			SemuaWilayah='$semua_wilayah', 
			SemuaPeraturan='$semua_peraturan', 
			Keterangan='$keterangan' 
		WHERE NIK='$nik'";
	$cat = "update"; // category query
	InsertDataEmp($conn,$sql,$cat,$nik);
}
elseif($show == "bahasa"){
	$sql 	= "WITH limit as (SELECT ROW_NUMBER() OVER (ORDER BY NIK) as No, * FROM Bahasa WHERE NIK='$nik') UPDATE limit SET Bahasa='$bahasa' WHERE No='$no'";
	$cat	= "update";
	InsertDataEmp($conn,$sql,$cat,$nik);
}
elseif($show == "ref_pengalaman_ln"){
	$d			= substr($dari,0,2); // day
	$m			= substr($dari,3,2); // month
	$y			= substr($dari,6,4); // year
	$tgl_dari 	= $y."-".$m."-".$d; // date yyyy-mm-dd

	$d1			= substr($sampai,0,2); // day
	$m1			= substr($sampai,3,2); // month
	$y1			= substr($sampai,6,4); // year
	$tgl_sampai	= $y1."-".$m1."-".$d1; // date yyyy-mm-dd

	$sql 	= "WITH limit as (SELECT ROW_NUMBER() OVER (ORDER BY NIK) as No, * FROM PengalamanLN WHERE NIK='$nik') UPDATE limit SET Negara='$negara', Dari='$tgl_dari', Sampai='$tgl_sampai', Keterangan='$keterangan' WHERE No='$no'";
	$cat	= "update";
	InsertDataEmp($conn,$sql,$cat,$nik);
}
elseif($show == "ref_pengalaman"){
	$sql 	= "WITH limit as (SELECT ROW_NUMBER() OVER (ORDER BY NIK) as No, * FROM PengalamanRef WHERE NIK='$nik') UPDATE limit SET Nama='$nama', Alamat='$alamat', NoTelp='$telepon', Jabatan='$jabatan', Hubungan='$hubungan' WHERE No='$no'";
	$cat	= "update";
	InsertDataEmp($conn,$sql,$cat,$nik);
}
elseif($show == "emp_status" ){
	// tamat jabatan
	$d			= substr($tamat_jabatan,0,2); // day
	$m			= substr($tamat_jabatan,3,2); // month
	$y			= substr($tamat_jabatan,6,4); // year
	$TmtJabatan	= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tamat golongan
	$d1			= substr($tamat_golongan,0,2); // day
	$m1			= substr($tamat_golongan,3,2); // month
	$y1			= substr($tamat_golongan,6,4); // year
	$TmtGolongan= $y1."-".$m1."-".$d1; // date yyyy-mm-dd
	// tanggal masuk
	$d2			= substr($tgl_masuk,0,2); // day
	$m2			= substr($tgl_masuk,3,2); // month
	$y2			= substr($tgl_masuk,6,4); // year
	$TglMasuk	= $y2."-".$m2."-".$d2; // date yyyy-mm-dd
	// tanggal keluar
	$d3			= substr($tgl_keluar,0,2); // day
	$m3			= substr($tgl_keluar,3,2); // month
	$y3			= substr($tgl_keluar,6,4); // year
	$TglKeluar	= $y3."-".$m3."-".$d3; // date yyyy-mm-dd
	// tanggal nikah
	$d4			= substr($tgl_nikah,0,2); // day
	$m4			= substr($tgl_nikah,3,2); // month
	$y4			= substr($tgl_nikah,6,4); // year
	$TglNikah	= $y4."-".$m4."-".$d4; // date yyyy-mm-dd

//	$sql = "UPDATE KaryawanStatus SET stat_kar='$status_karyawan', stat_kerja='$status_kerja', jabatan='$jabatan', tmt_jab='$TmtJabatan', golongan='$golongan', tmt_gol='$TmtGolongan', fungsi='$fungsi', kode_so='$kode_so', tgl_masuk='$TglMasuk', tgl_keluar='$TglKeluar', tgl_nikah='$TglNikah' WHERE NIK='$nik'";

	$sql = "UPDATE KaryawanStatus SET tgl_masuk='$TglMasuk', tgl_keluar='$TglKeluar', tgl_nikah='$TglNikah' WHERE NIK='$nik' ";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE DATA KARIR DI PTSI
elseif($show == "karir_ptsi" ){
	// tamat jabatan
	$d			= substr($tgl_efektif,0,2); // day
	$m			= substr($tgl_efektif,3,2); // month
	$y			= substr($tgl_efektif,6,4); // year
	$TglEfektif	= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tamat golongan
	$d1			= substr($tgl_skd,0,2); // day
	$m1			= substr($tgl_skd,3,2); // month
	$y1			= substr($tgl_skd,6,4); // year
	$TglSKD= $y1."-".$m1."-".$d1; // date yyyy-mm-dd
	// tanggal masuk
	$d2			= substr($tgl_selesai,0,2); // day
	$m2			= substr($tgl_selesai,3,2); // month
	$y2			= substr($tgl_selesai,6,4); // year
	$TglSelesai	= $y2."-".$m2."-".$d2; // date yyyy-mm-dd

	$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM KarirPTSI WHERE NIK='$nik') UPDATE limit SET  no_surat='$no_surat', tgl_efektif='$TglEfektif', tgl_skd='$TglSKD', tgl_selesai='$TglSelesai', kelompok='$kelompok', lokasi2='$lokasi1', kode_so2='$kode_so', jabatan2='$jabatan1', fungsi2='$fungsi1', gol2='$gol1', stat_kar2='$status_karyawan1', jabatan1='$jabatan2', fungsi1='$fungsi2', keterangan='$keterangan', Jenis='$jenis_surat' WHERE No='$no'";
	
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE TRACK RECORD
elseif($show == "track_record" ){
	// tamat jabatan
	$d			= substr($track_start,0,2); // day
	$m			= substr($track_start,3,2); // month
	$y			= substr($track_start,6,4); // year
	$TS			= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tamat golongan
	$d1			= substr($track_end,0,2); // day
	$m1			= substr($track_end,3,2); // month
	$y1			= substr($track_end,6,4); // year
	$TE 		= $y1."-".$m1."-".$d1; // date yyyy-mm-dd


	// bukan approval
	if(trim($HTTP_POST_VARS['approval']) == ""){
		$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM MK_TrackRecords WHERE NIK='$nik') UPDATE limit SET  Track_start='$TS', Track_end='$TE', Client='$client', Product='$product', Project='$project', Job_Desc='$job_desc' WHERE No='$no'";
		$cat = "update";
		InsertData($conn,$sql,$cat);
	}
	elseif($HTTP_POST_VARS['approval'] == "yes"){
		$sql = mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM MK_TrackRecords WHERE NIK='$nik' ) UPDATE limit SET aktif='A' WHERE No='$no'",$conn);
		if($sql){
			echo"
				<div align=center>
				<br><br><br><br>
				Data Track Record untuk karyawan dengan <b>NIK: $nik</b> sudah disetujui dan terdaftar dalam CV Online.<br><br>
				<a href='Javascript:history.go(-2);'>Silahkan kembali</a>
				</div>
			";
		}
		else{
			echo"
				<div align=center>
				<br><br><br><br>
				Data Track Record untuk karyawan dengan <b>NIK: $nik</b> gagal untuk diproses...<br><bR>
				<a href='Javascript:history.back();'>Silahkan kembali</a>
				</div>
			";		
		}
	}
	
}
// UPDATE SANKSI
elseif($show == "sanksi" ){
	// tamat jabatan
	$d			= substr($tgl_berlaku,0,2); // day
	$m			= substr($tgl_berlaku,3,2); // month
	$y			= substr($tgl_berlaku,6,4); // year
	$TglBerlaku	= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tamat golongan
	$d1			= substr($tgl_keluar,0,2); // day
	$m1			= substr($tgl_keluar,3,2); // month
	$y1			= substr($tgl_keluar,6,4); // year
	$TglKeluar	= $y1."-".$m1."-".$d1; // date yyyy-mm-dd
//	echo"$no";
//	exit();
	$sql = " WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM Sanksi WHERE NIK='$nik') UPDATE limit SET no_surat='$no_surat', tgl_laku='$TglBerlaku', tgl_luar='$TglKeluar', sanksi='$sanksi', keterangan='$keterangan', category='".$HTTP_POST_VARS['katsanksi']."' WHERE No='$no'";
		
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE PENUGASAN
elseif($show == "penugasan" ){
	// tanggal dari
	$d			= substr($tgl_dari,0,2); // day
	$m			= substr($tgl_dari,3,2); // month
	$y			= substr($tgl_dari,6,4); // year
	$TglDari	= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tanggal sampai
	$d1			= substr($tgl_sampai,0,2); // day
	$m1			= substr($tgl_sampai,3,2); // month
	$y1			= substr($tgl_sampai,6,4); // year
	$TglSampai	= $y1."-".$m1."-".$d1; // date yyyy-mm-dd
	// tanggal surat
	$d2			= substr($tgl_surat,0,2); // day
	$m2			= substr($tgl_surat,3,2); // month
	$y2			= substr($tgl_surat,6,4); // year
	$TglSurat	= $y2."-".$m2."-".$d2; // date yyyy-mm-dd
		
	$sql = " WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM Penugasan WHERE NIK='$nik') UPDATE limit SET NIK='$nik', no_surat='$no_surat', tgl_surat='$TglSurat', tujuan='$tujuan', dari_tgl='$TglDari', sampai_tgl='$TglSampai', keperluan='$keperluan' WHERE No='$no'";
		
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE PENILAIAN
elseif($show == "penilaian"){
	$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM LP2DEtail WHERE NIK='$nik') UPDATE limit SET unsur='$unsur', nilai1='$nilai1', nilai2='$nilai2', nilai3='$nilai3', catatan='$catatan' WHERE No='$no' ";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE LP2 ////TIDAK DIPAKAI
elseif($show == "LP2"){
	$sql = "UPDATE LP2 SET penilai1='$nama', penilai2='$nama2', penilai3='$nama3' WHERE NIK='$nik4'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE LP // INI YANG DIPAKAI
elseif($show == "LP"){
	$sql = "UPDATE S_LP SET NIK='$nik', periode='$tahun', penilai_atasan1='$penilai_atasan1', penilai_atasan2='$penilai_atasan2', penilai_peers1='$penilai_peers1', penilai_peers2='$penilai_peers2', penilai_peers3='$penilai_peers3', penilai_adum='$penilai_adum' WHERE id='$id'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}

// UPDATE CUTI KHUSUS
elseif($show == "cuti_khusus"){
	// tanggal mulai
	$d			= substr($tgl_mulai,0,2); // day
	$m			= substr($tgl_mulai,3,2); // month
	$y			= substr($tgl_mulai,6,4); // year
	$TglMulai	= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tanggal sampai
	$d1			= substr($tgl_selesai,0,2); // day
	$m1			= substr($tgl_selesai,3,2); // month
	$y1			= substr($tgl_selesai,6,4); // year
	$TglSelesai	= $y1."-".$m1."-".$d1; // date yyyy-mm-dd

	$sql = "UPDATE Cuti SET tgl_awal='$TglMulai', tgl_akhir='$TglSelesai', jml_cuti='$jumlah_cuti', keterangan='$keterangan', id_JenisCuti='$jenis_cuti' WHERE id='$no'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE CUTI TAHUNAN
elseif($show == "cuti_tahunan"){
	// tanggal mulai
	$d			= substr($tgl_mulai,0,2); // day
	$m			= substr($tgl_mulai,3,2); // month
	$y			= substr($tgl_mulai,6,4); // year
	$TglMulai	= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tanggal sampai
	$d1			= substr($tgl_selesai,0,2); // day
	$m1			= substr($tgl_selesai,3,2); // month
	$y1			= substr($tgl_selesai,6,4); // year
	$TglSelesai	= $y1."-".$m1."-".$d1; // date yyyy-mm-dd
	// tanggal hangus
	$d2			= substr($tgl_hangus,0,2); // day
	$m2			= substr($tgl_hangus,3,2); // month
	$y2			= substr($tgl_hangus,6,4); // year
	$TglHangus	= $y2."-".$m2."-".$d2; // date yyyy-mm-dd
	

	//$periode_tahun = $HTTP_POST_VARS['periode1']." - ".$HTTP_POST_VARS['periode2'];
	$periode_tahun = $HTTP_POST_VARS['periode1'];
	$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM CutiTahunan WHERE NIK='$nik' ) 
	UPDATE limit SET periode='$periode_tahun', tgl_cuti='$TglMulai', tgl_hangus='$TglHangus', tgl_selesai='$TglSelesai', keterangan='$keterangan', tunda='".$HTTP_POST_VARS['tunda']."', ambil='".$HTTP_POST_VARS['ambil']."' WHERE id='$no'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE CUTI TAHUNAN ED
elseif($show == "cuti_tahunan_ed"){
	// tanggal mulai
	$d			= substr($tgl_mulai,0,2); // day
	$m			= substr($tgl_mulai,3,2); // month
	$y			= substr($tgl_mulai,6,4); // year
	$TglMulai	= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tanggal sampai
	$d1			= substr($tgl_selesai,0,2); // day
	$m1			= substr($tgl_selesai,3,2); // month
	$y1			= substr($tgl_selesai,6,4); // year
	$TglSelesai	= $y1."-".$m1."-".$d1; // date yyyy-mm-dd
	// tanggal hangus
	$d2			= substr($tgl_hangus,0,2); // day
	$m2			= substr($tgl_hangus,3,2); // month
	$y2			= substr($tgl_hangus,6,4); // year
	$TglHangus	= $y2."-".$m2."-".$d2; // date yyyy-mm-dd
	

	//$periode_tahun = $HTTP_POST_VARS['periode1']." - ".$HTTP_POST_VARS['periode2'];
	$periode_tahun = $HTTP_POST_VARS['periode1'];
	///*
	$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY Periode) AS No, * FROM CutiTahunan WHERE NIK='$nik' ) 
	UPDATE limit SET tgl_cuti='$TglMulai', tgl_hangus='$TglHangus', tgl_selesai='$TglSelesai', keterangan='$keterangan', tunda='".$HTTP_POST_VARS['tunda']."', ambil='".$HTTP_POST_VARS['ambil']."' WHERE id='$no' AND periode='$periode_tahun'";
	//*/
	//$sql = "UPDATE CutiTahunan SET tgl_cuti='$TglMulai', tgl_hangus='$TglHangus', tgl_selesai='$TglSelesai', keterangan='$keterangan', tunda='".$HTTP_POST_VARS['tunda']."', ambil='".$HTTP_POST_VARS['ambil']."' WHERE No='$no' AND periode='$periode_tahun' AND NIK='$nik' ";
	$cat = "update";
	//echo"$sql";
	InsertData($conn,$sql,$cat);
}
// CUTI BESAR
elseif($show == "cuti_besar"){
	// tanggal mulai
	$d			= substr($tgl_mulai,0,2); // day
	$m			= substr($tgl_mulai,3,2); // month
	$y			= substr($tgl_mulai,6,4); // year
	$TglMulai	= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tanggal sampai
	$d1			= substr($tgl_selesai,0,2); // day
	$m1			= substr($tgl_selesai,3,2); // month
	$y1			= substr($tgl_selesai,6,4); // year
	$TglSelesai	= $y1."-".$m1."-".$d1; // date yyyy-mm-dd

	//$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY periode) AS No, * FROM Cuti WHERE NIK='$nik' AND periode='".$HTTP_POST_VARS['periode']."' ) 
	//UPDATE limit SET tgl_awal='$TglMulai', tgl_akhir='$TglSelesai', keterangan='$keterangan', jml_cuti='$jumlah_cuti' WHERE id='$no'";
	$sql = "UPDATE Cuti SET tgl_awal='$TglMulai', tgl_akhir='$TglSelesai', keterangan='$keterangan', jml_cuti='$jumlah_cuti' WHERE id='$no'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE PLAFON AWAL
elseif($show == "plafon_awal"){
	// tanggal setup
	$d			= substr($date_setup,0,2); // day
	$m			= substr($date_setup,3,2); // month
	$y			= substr($date_setup,6,4); // year
	$TglMulai	= $y."-".$m."-".$d; // date yyyy-mm-dd
	$sql = "WITH Q AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM MedicalSetupAwal WHERE NIK='$nik' ) UPDATE Q SET DateSetup='$TglMulai', Periode='$periode', PlafonRawatJalan='$plafon_rawat_jalan', PlafonRawatInap='$plafon_rawat_inap', PlafonKacaMata='$plafon_kaca_mata' WHERE No='$no'";
	
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE REKENING
elseif($show == "rekening"){
	$sql = "UPDATE MedicalNoRekening SET no_rek='$no_rek', nama_rek='$nama_rek', IdBank='$nama_bank' WHERE NIK='$nik'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE DATA MEDICAL
elseif($show == "medical"){
	// tanggal restitusi
	$d			= substr($tgl_restitusi,0,2); // day
	$m			= substr($tgl_restitusi,3,2); // month
	$y			= substr($tgl_restitusi,6,4); // year
	$TglRestitusi	= $y."-".$m."-".$d; // date yyyy-mm-dd

	$dd 		= substr($HTTP_POST_VARS['tgl_bayar'],0,2);
	$mm 		= substr($HTTP_POST_VARS['tgl_bayar'],3,2);
	$yy 		= substr($HTTP_POST_VARS['tgl_bayar'],6,4);
	
	$TglBayar	= $yy."-".$mm."-".$dd;
	// getpemeriksa
	$sqlriksa	= mssql_query("SELECT NIK,Nama FROM Karyawan WHERE NIK='".$_SESSION['user_login']."'",$conn);
	$rowriksa	= mssql_fetch_array($sqlriksa);
	if(mssql_num_rows($sqlriksa) > 0){
		$pemeriksa = $rowriksa[Nama];
	}
	else{
		$pemeriksa = $_SESSION['user_login'];
	}

	if($HTTP_POST_VARS['status'] == "medical_edit"){
		// get jumlah restitusi
		$sql3 = mssql_query("SELECT * FROM MedicalRestitusiDetail WHERE NIK='".$nik."' AND nomor='".$no_restitusi."'",$conn);
		$cnt3 = mssql_num_rows($sql3);
		if($cnt3 > 0){
			for($m=1;$m<=$cnt3;$m++){
		
					$sql = "UPDATE MedicalRestitusiDetail SET nama_tertanggung='".$HTTP_POST_VARS['nama_tertanggung'.$m.'']."', status_kel='".$HTTP_POST_VARS['status_keluarga'.$m.'']."',nama_dokter='".$HTTP_POST_VARS['nama_dokter'.$m.'']."',jml_diajukan='".$HTTP_POST_VARS['diajukan'.$m.'']."', remarks='".$HTTP_POST_VARS['remarks'.$m.'']."', tgl_bayar='$TglBayar' WHERE NIK='$nik' AND nomor='$no_restitusi' AND id_trans='".$HTTP_POST_VARS['ID'.$m.'']."'";
					
					$cat = "update";
					InsertData($conn,$sql,$cat);
						
			}
		}
		else{
		}
	}
	elseif($HTTP_POST_VARS['status'] == "medical_setuju"){
		// get jumlah restitusi
		$sql3 = mssql_query("SELECT * FROM MedicalRestitusiDetail WHERE NIK='".$nik."' AND nomor='".$no_restitusi."'",$conn);
		$cnt3 = mssql_num_rows($sql3);
		if($cnt3 > 0){
			for($m=1;$m<=$cnt3;$m++){
		
					$sql = "UPDATE MedicalRestitusiDetail SET nama_tertanggung='".$HTTP_POST_VARS['nama_tertanggung'.$m.'']."', status_kel='".$HTTP_POST_VARS['status_keluarga'.$m.'']."',nama_dokter='".$HTTP_POST_VARS['nama_dokter'.$m.'']."',jml_diajukan='".$HTTP_POST_VARS['diajukan'.$m.'']."', mata_anggaran='".$HTTP_POST_VARS['mata_anggaran'.$m.'']."', jml_disetujui='".$HTTP_POST_VARS['disetujui'.$m.'']."', status='A',DiperiksaBy='$pemeriksa', tgl_bayar='$TglBayar', remarks='".$HTTP_POST_VARS['remarks'.$m.'']."' WHERE NIK='$nik' AND nomor='$no_restitusi' AND id_trans='".$HTTP_POST_VARS['ID'.$m.'']."'";
					
					$cat = "update";
					//echo"$sql <br><br>".$HTTP_POST_VARS['id_res'.$m.''];
					InsertData($conn,$sql,$cat);
						//echo"fff";
			}
		}
		else{
		}
	}
}
// MEDICAL DISETUJUI
elseif($show == "medical_setuju"){
	// tanggal restitusi
	$d			= substr($tgl_restitusi,0,2); // day
	$m			= substr($tgl_restitusi,3,2); // month
	$y			= substr($tgl_restitusi,6,4); // year
	$TglRestitusi	= $y."-".$m."-".$d; // date yyyy-mm-dd
	// tanggal bayar
	$d1			= substr($tgl_bayar,0,2); // day
	$m1			= substr($tgl_bayar,3,2); // month
	$y1			= substr($tgl_bayar,6,4); // year
	$TglBayar	= $y1."-".$m1."-".$d1; // date yyyy-mm-dd
	// tanggal kwitansi
	$d2			= substr($tgl_kwitansi,0,2); // day
	$m2			= substr($tgl_kwitansi,3,2); // month
	$y2			= substr($tgl_kwitansi,6,4); // year
	$TglKwitansi	= $y2."-".$m2."-".$d2; // date yyyy-mm-dd

//	echo"OK<br>$nik, $periode, ".$no_restitusi."<br>";exit;
	//$sql_update_medical	= mssql_query("UPDATE MedicalRestitusi SET tanggal='$TglRestitusi', klaim_RJ='$klaim_RJ', klaim_RI='$klaim_RI', klaim_KM='$klaim_KM', setuju_RJ='20000', setuju_KM='$setuju_KM', RI_Prsh='$beban_RI_prsh', RI_Kar='$beban_RI_kar', tgl_bayar='$TglBayar', RP_Prsh='$beban_PR_prsh', RP_Kar='$beban_PR_kar', DiperiksaBy='$diperiksa_oleh', DiAjukanBy='$diajukan_oleh'	WHERE NIK='$nik' AND Periode='$periode' AND nomor='$no_restitusi' ", $conn);
	
	 $sql_update_medical	= mssql_query("UPDATE MedicalRestitusi SET setuju_RJ='20000', setuju_KM='1500', RI_Prsh='$beban_RI_prsh', RI_Kar='$beban_RI_kar', RP_Prsh='$beban_PR_prsh', RP_Kar='$beban_PR_kar', DiperiksaBy='$diperiksa_oleh' WHERE NIK='$nik' AND Periode='$periode' AND nomor='$no_restitusi' ", $conn);
	 
	$jml_klaim	= ($klaim_KM+$klaim_RI+$klaim_RJ);
	$jml_setuju	= ($setuju_KM+$setuju_RJ);
	
	if($sql_update_medical){
		$sql = "UPDATE MedicalRestitusiDetail SET tanggal='$TglKwitansi', nama_tertanggung='$nama_tertanggung', status_kel='$status_kel_restitusi', nama_dokter='$nama_dokter', mata_anggaran='$mata_anggaran', jml_diajukan='$jml_klaim', jml_disetujui='$jml_setuju', cara_bayar='$cara_bayar' WHERE NIK='$nik' AND Periode='$periode' AND nomor='$no_restitusi' ";

		$cat = "update";
		InsertData($conn,$sql,$cat);	
	}
	else{
		//include("../header.php");
		echo"
		<div align=center style='color: red;'>
		Update data tidak dapat dilakukan, ... <br><br>
		[ <a href='Javascript:history.back();'>kembali</a> ]		
		";
	}
//	*/
}

// UPDATE PARAMETER LOKASI
elseif($show == "par_lokasi"){
	$sql = "UPDATE MstLokasi SET distrik='$distrik', propinsi='$propinsi' WHERE kode_lokasi='$kode_lokasi'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE PARAMETER LOKASI
elseif($show == "par_lp2"){
	$sql = "UPDATE MstUnsurLP2 SET UnsurName='$unsur_nilai' WHERE UnsurID='$kode_nilai'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE PARAMETER fungsional
elseif($show == "par_fungsional"){
	$sql = "UPDATE MstFungsional SET nama='$nama_fungsi' WHERE kode='$kode_fungsi'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE PARAMETER JENIS CUTI
elseif($show == "par_jns_cuti"){
	$sql = "UPDATE MstJenisCuti SET uraian='$nama_cuti', jatah_cuti='$jatah_cuti', syarat_waktu='$syarat_waktu', akumulasi='$akumulasi', otorisasi='$otorisasi', istimewa='$istimewa', syarat_sex='$syarat_sex' WHERE id_jcuti='$no'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE PARAMETER PENDIDIKAN
elseif($show == "par_pendidikan"){
	$sql = "UPDATE MstPendidikan SET keterangan='$jenjang', fakultas='$fakultas', jurusan='$jurusan', teknik='$teknik' WHERE Pend_ID='$no'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE PARAMETER BANK
elseif($show == "par_bank"){
	$sql = "UPDATE MstBank SET NamaBank='$nama_bank', Alamat='$cabang' WHERE IdBank='$no'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE PARAMETER JABATAN
elseif($show == "par_jabatan"){
	$sql = "UPDATE MstJabatan SET jabatan='$jabatan', nama='$nama_jabatan', fungsional='$fungsional', level_jbt='$level_jabatan' WHERE kode='$no'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE PARAMETER SETUP
elseif($show == "par_setup"){
	$sql = "UPDATE MstData SET Remarks='$remarks', IDCode='$idcode' WHERE GroupCode='$groupcode' AND Code='$code'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE USER
elseif($show == "add_user"){
	$sql = "UPDATE S_User SET groupid='$group_code' WHERE username='$username'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
}
// UPDATE GROUP USER
elseif($show == "add_group"){
/*
	$cntg = count($menuname);
	for($j=0;$j<$cntg;$j++){
		mssql_query("UPDATE S_Priv_User SET hakakses='$priv[$j]' WHERE group_id='$group_code' AND nama_menu='$menuname[$j]'",$conn);
	}
	
	$sql = "UPDATE S_User_Group SET group_name='$group_name', note='$keterangan' WHERE group_id='$group_code'";
	$cat = "update";
	InsertData($conn,$sql,$cat);
	*/
	$cntmenu	= count($menuname);
	/*
	for($f=0;$f<$cntmenu;$f++){
	mssql_query("UPDATE S_Priv_User SET tambah='".$HTTP_POST_VARS["add_".$menuname[$f].""]."', edit='".$HTTP_POST_VARS["edit_".$menuname[$f].""]."', hapus='".$HTTP_POST_VARS["delete_".$menuname[$f].""]."', baca='".$HTTP_POST_VARS["view_".$menuname[$f].""]."', approval='".$HTTP_POST_VARS["approval_".$menuname[$f].""]."' WHERE nama_menu='".$menuname[$f]."' AND group_id='$group_code' ",$conn);
	}
	*/
	// hapus dulu
	$qdel = mssql_query("DELETE FROM S_Priv_User WHERE group_id='$group_code'");
	if($qdel){
		for($f=0;$f<$cntmenu;$f++){
			mssql_query("INSERT INTO S_Priv_User (group_id, nama_menu, tambah, edit, hapus, baca, approval) VALUES ('$group_code','$menuname[$f]','".$HTTP_POST_VARS["add_".$menuname[$f].""]."', '".$HTTP_POST_VARS["edit_".$menuname[$f].""]."', '".$HTTP_POST_VARS["delete_".$menuname[$f].""]."', '".$HTTP_POST_VARS["view_".$menuname[$f].""]."', '".$HTTP_POST_VARS["approval_".$menuname[$f].""]."')",$conn);
		}
	}

//update table group user
$sql	= "UPDATE S_User_Group SET group_name='$group_name', note='$keterangan' WHERE group_id='$group_code'";
$cat = "update";
InsertData($conn,$sql,$cat);

}
// RESET PASSWORD
elseif($show == "reset_pass"){
	$sql = "UPDATE S_User SET password='".md5($password)."' WHERE username='$username'";
	$cat = "update";
	InsertData($conn,$sql,$cat);	
}
// CHANGE PASSWORD
elseif($show == "ch_pass"){
	$sqlU = mssql_query("SELECT * FROM S_User WHERE username='$username' and password='".md5($pass_lama)."'");
	if(mssql_num_rows($sqlU) > 0){
		$sql = "UPDATE S_User SET password='".md5($conf_pass_baru)."' WHERE username='$username'";
		$cat = "update";
		InsertData($conn,$sql,$cat);	
	}
	else{
//		include("../headL.php");
		echo"
		<br><br><br>
		 <div align=center style=color:red;>
		  Maaf, Password Lama Anda Salah ...<br><br>
		  [ <a href='Javascript:history.back();'>kembali</a> ]
		 </div>
		";
	}
}
// UPDATE TABLE UNIT KERJA
elseif($show == "tbl_unit_kerja"){
	$sql = "UPDATE MstSO Set uraian='$uraian', LevelSO='$levelso', golongan='$golongan', status='$status', kode_lokasi='$kode_lokasi', AreaCode='$areacode' WHERE kode_so='".$HTTP_POST_VARS['kode_so1']."'";
	$cat = "update";
	InsertData($conn,$sql,$cat);	
}
// UPDATE SERTIFIKASI
elseif($show == "certified"){
//NIK,seqno,Cert_No,Cert_Name,Cert_Desc,Cert_Start,Cert_End,Cert_Date,Cert_Date_Exp

	// tanggal sertifikat
	$d2			= substr($tgl_sertifikat,0,2); // day
	$m2			= substr($tgl_sertifikat,3,2); // month
	$y2			= substr($tgl_sertifikat,6,4); // year
	$TglSertifikat	= $y2."-".$m2."-".$d2; 
	// tanggal kadalurasa
	$d1			= substr($tgl_kadaluarsa,0,2); // day
	$m1			= substr($tgl_kadaluarsa,3,2); // month
	$y1			= substr($tgl_kadaluarsa,6,4); // year
	$TglKadaluarsa = $y1."-".$m1."-".$d1; 
	
	$sql = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY Cert_Date) AS No, * FROM MK_Certification WHERE NIK='$nik')
	UPDATE limit SET Cert_No='$no_sertifikat', Cert_Name='$nama_sertifikat', Cert_Desc='$keterangan', Cert_Date='$TglSertifikat', Cert_Date_Exp='$TglKadaluarsa' WHERE No='$no'";
	$cat = "update";
	InsertData($conn,$sql,$cat);	
}

echo"</div>
	  </td>
	   </tr>
	    </table>
";
include("../menu.php");
?>
